package io;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class CopyDemo2 {
    public static void main(String[] args) throws IOException {
        FileInputStream fis= new FileInputStream("风景1.png");
        FileOutputStream fos = new FileOutputStream("风景3.png");

        long start = System.currentTimeMillis();
        byte []arr=new byte[1024*10];
        int len;
        while ((len=fis.read(arr))!=-1){
            fos.write(arr,0,len);
        }

        long end = System.currentTimeMillis();
        System.out.println("复制完毕，总用时"+(end-start)+"ms");
/*
        long start = System.currentTimeMillis();
        byte []arr=new byte[1024*10];
        while ((fis.read(arr))!=-1){
            fos.write(arr);
        }
        long end = System.currentTimeMillis();
        System.out.println("复制完毕，总用时"+(end-start)+"ms");

 */
        fis.close();
        fos.close();

        FileInputStream f1 =new FileInputStream("风景1.png");
        FileOutputStream f2=new FileOutputStream("风景4.png");
        long start1= System.currentTimeMillis();
        int len1;
        byte [] art=new byte[1024*100];
        while ((len1=f1.read(art))!=-1){
            f2.write(art,0,len1);
        }
        long end1=System.currentTimeMillis();
        System.out.println("创建完毕，用时："+(end1-start1));

    }
}
